Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

[Enhancement] Refactor command_execution_time segment #1215

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ChrisBaker97
Copy link
Contributor

This is a back-port of #1214 on the next branch.

I wanted to add an "s" after the seconds display, in the case that the execution time was under a minute, to make it clearer what units were being displayed, when there were no colons.

In the process of investigating this modification, I noticed that the code for formatting either whole or partial seconds (depending on the POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION variable) seemed unnecessarily complex. By eliminating the pre-declaration of the number type and replacing it with a printf statement to format on the fly, I was able to squash a three-way if/elif/else control structure into a single line.

I also noticed that all this formatting was being done every time, regardless of whether the execution time actually exceeded the threshold, so I moved that logic to the front of the module, so that none of those computations happen if nothing will be displayed anyway.

romkatv added a commit to romkatv/powerlevel10k that referenced this pull request Jun 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant